import Data.List
primes = 2 : filter ( (==1) . length . primeFactors ) [3,5..]

primeFactors :: Integer -> [Integer]
primeFactors n = factor n primes
	where
	factor n (p:ps)
		| p*p > n		 = [n]
		| n `mod` p == 0 = p : factor ( n `div` p )	(p:ps)
		| otherwise		 = factor n ps

factors :: Integer -> [Integer]
factors 1 = [1]
factors n
	| length (t) == 1 = [1,n]
	| otherwise = nub $ map product $ subsequences t
	where t = primeFactors n
	
properFactors :: Integer -> [Integer]
properFactors n = (factors n)\\[n]

sumProperFactors :: Integer -> Integer
sumProperFactors n = sum $ properFactors n

euler_021 = sum [(x+y) | x<-[2..10000],let y=sumProperFactors(x), x == sumProperFactors(y),x /= y, x < y]